<admintpl file="header" />
</head>
<body>
<div class="wrap js-check-wrap">
	<ul class="nav nav-tabs">
		<li class="active"><a href="{:U('Money/get_sum')}">流动资金分析</a></li>
	</ul>
	<p>时间：
		<input type="text" name="begin_date" class="js-datetime" value="{$formget.start_time|default=''}" style="width: 120px; margin-top:10px;" autocomplete="off">-
		<input type="text" class="js-datetime" name="end_date" value="{$formget.end_time|default=''}" style="width: 120px; margin-top:10px;" autocomplete="off">
		<input type="submit" class="btn btn-primary" name="submit" value="确定">
	</p>
	<!--总统计-->
	<div class="well text-center" style="overflow: hidden; background: #f4f4f4;">
		<div style="float: left; width:33%; padding: 40px 0; border-right:1px solid #fcfcfc;">
			<p>微信支付：￥<b class="pay_wxpay">0</b></p>

			<p>余额支付：￥<b class="pay_balance">0</b></p>
			<p>支付总金额：￥<b class="pay_amount">0</b></p>
			<p>支付总次数：<b class="pay_num">0</b></p>
			<p>微信支付用户：<b class="pay_user">0</b></p>
		</div>
		<div style="float: left; width:33%; padding: 40px 0; border-right:1px solid #fcfcfc; border-left:1px solid #e5e5e5">
			<p>抽佣金额：￥<b class="profit_amount">0</b></p>

			<p>提现总金额：￥<b class="wd_amount">0</b></p>
			<p>提现实际金额：￥<b class="wd_true_amount">0</b></p>
			<p>提现次数：<b class="wd_num">0</b></p>

		</div>
		<div style="float: left; width:33%; padding: 40px 0;  border-left:1px solid #e5e5e5">
			<p>用户余额：￥<b class="user_amount">0</b></p>

			<p>未支付金额：￥<b class="unpay_amount">0</b></p>
			<p>未支付次数：<b class="unpay_num">0</b></p>
		</div>
	</div>
	<div id="line" style="width:100%;height:492px;"></div>
</div>

<script src="__PUBLIC__/js/common.js"></script>
<script src="__PUBLIC__/js/echarts/echarts.min.js"></script>
<!--<script src="__PUBLIC__/js/layer/layer.js"></script>-->

<script>
	var  InfoObject = {};
    //趋势图变量初始化
    var userInfoObject={},
        $info={
            //饼图
            chart:function () {
                var myChart = echarts.init(document.getElementById('line'));
                var option = {
                    title: {
                        text: '流动资金分析图',
                        x:'center'
                    },
                    tooltip: {
                        trigger: 'item',
                        formatter: "{a} <br/>{b} : {c} ({d}%)>"
                        //饼图中{a}表示系列名称，{b}表示数据项名称，{c}表示数值，{d}表示百分比
                    },
                    legend: {
                        //图例
                        orient: 'vertical',
                        left: 'left',
                        data: ['微信支付金额','用户余额','提现实际金额','抽佣金额']
                    },
                    series: [{
                        name: '来源',
                        type: 'pie',
                        radius: '55%',
                        data: [
                            {value:InfoObject.pay_wxpay,name:'微信支付金额'},
                            {value:InfoObject.user_amount,name:'用户余额'},
                            {value:InfoObject.wd_true_amount,name:'提现实际金额'},
                            {value:InfoObject.profit_amount,name:'抽佣金额'},
                        ],
                        itemStyle: {
                            //itemStyle有正常显示：normal，有鼠标hover的高亮显示：emphasis
                            emphasis:{
                                //normal显示阴影,与shadow有关的都是阴影的设置
                                shadowBlur:10,//阴影大小
                                shadowOffsetX:0,//阴影水平方向上的偏移
                                shadowColor:'rgba(0,0,0,0.5)'//阴影颜色
                            },
                            normal:{
                                label:{
                                    show: true,
                                    formatter: '{b} : {c} ({d}%)'
                                },
                                labelLine :{show:true}
                            }
                        }
                    }]
                };
                myChart.setOption(option);

            },
            //异步请求方法
            get_info:function(url,data,callback){
                //获取用户数据
                $.ajax({
                    url: url,
                    type: "POST",
                    dataType: "json",
                    data: data,
                    success: function (data) {
                        callback(data);
                    }
                });
            },
            //设置数据到页面
            set_info:function(res){
                var new_user=0,cancel_user=0,increase_user=0,cumulate_user=0;
                if(res.code!==20000){
                    var msg=res.msg || res.info
                    layer.alert(msg, {
                        skin: 'layui-layer-molv' //样式类名
                        ,closeBtn: 0
                        ,anim: 4 //动画类型
                    });
                    return false;
                }
                //初始化饼图值
                if(res.data!=''){
                    var $data = res.data;
                    InfoObject={
						pay_num:$data.pay_count.total_num,
						pay_amount:$data.pay_count.total_amount,
						pay_wxpay:$data.pay_count.wxpay_amount,
						pay_balance:$data.pay_count.balance_amount,
                        unpay_amount:$data.pay_count.unpay_amount,
                        unpay_num:$data.pay_count.unpay_num,
                        pay_user:$data.pay_count.pay_user,
						wd_num:$data.wd_count.total_num,
						wd_amount:$data.wd_count.total_amount,
                        wd_true_amount:$data.wd_count.true_amount,
						profit_amount:$data.wd_count.profit_amount,
						user_amount:$data.user_amount,
                    };
                    //总体统计赋值
                    $('.pay_num').text(InfoObject.pay_num);
                    $('.pay_amount').text(InfoObject.pay_amount);
                    $('.pay_wxpay').text(InfoObject.pay_wxpay);
                    $('.pay_balance').text(InfoObject.pay_balance);
                    $('.unpay_amount').text(InfoObject.unpay_amount);
                    $('.unpay_num').text(InfoObject.unpay_num);
                    $('.pay_user').text(InfoObject.pay_user);
                    $('.wd_num').text(InfoObject.wd_num);
                    $('.wd_amount').text(InfoObject.wd_amount);
                    $('.wd_true_amount').text(InfoObject.wd_true_amount);
                    $('.profit_amount').text(InfoObject.profit_amount);
                    $('.user_amount').text(InfoObject.user_amount);
                    $info.chart();
                }
            },
            //初始化开始、结束时间
            get_time:function(data){
                data= data * 24 || 24
                var myDate = new Date();
                //myDate.setTime(myDate.getTime() - data*60*60*1000);
                myDate.setTime(myDate.getTime());
                s = myDate.getFullYear()+"-" + (myDate.getMonth()+1) + "-" + myDate.getDate();
                return  s;
            }
        }
    //初始化调取
    var star_time = $info.get_time(1)+' 00:00';
    var end_time = $info.get_time()+' 23:59';
    $('input[name="begin_date"]').val(star_time);
    $('input[name="end_date"]').val(end_time);
    var url="{:U('Money/get_sum')}",
        data = {begin_date: star_time,end_date: end_time};
        $info.get_info(url,data,$info.set_info);

    //确定查询时间
    $('input[name="submit"]').on('click',function(){
        data = {begin_date: $('input[name="begin_date"]').val(),end_date: $('input[name="end_date"]').val()};
        $info.get_info(url,data,$info.set_info);
    })
</script>
</body>
</html>
